<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>缩放</title>
</head>
<body>
<script>
    function draw() {
        var canvas = document.getElementById("myCanvas");
        var context = canvas.getContext("2d");
        context.fillStyle="red"
        context.fillRect(0,0,50,50);
        context.scale(1.5,2.5);
        context.fillRect(120,0,60,80);
        context.scale(0.5,0.5);
        context.fillRect(160,0,80,90);
    }

</script>
<canvas id="myCanvas" width="600" height="400" style="border:1px solid #d3d3d3;">
</canvas>
<p><button type="button" onclick="draw();">绘图</button></p>
</body>
</html>